package learning.directory.Work.排序.Ygr;

import java.util.Arrays;

/**
 * @author yangguangrun
 * @date 2021/2/18 10:19 下午
 * 1. 冒泡排序(要排序数组:[10,1,35,61,89,36,55]),正序排序,类命名格式BubbleSort_day1
 */
public class BubbleSort_day1 {
    public static void main(String[] args) {
        int[] list = {10,1,35,61,89,36,55};
        sort(list);
    }

    public static void sort(int[] list){
        int a = 0;
        for (int i=0;i<list.length;i++){
            for (int j=0;j<list.length-1;j++){
                if (list[j]>list[j+1]){
                    a = list[j+1];
                    list[j+1] = list[j];
                    list[j] = a;
                }
            }
        }
        System.out.println(Arrays.toString(list));
    }
}
